﻿namespace ExamV5.PaperInfo
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmShowSelectTypeJ : Page
    {
        protected GridView DataGridInfo;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private HttpCookie httpCookie_4 = null;
        private PublicFun publicFun_0 = new PublicFun();
        private string string_0 = "0";
        private string string_1 = "A";
        private string string_2 = "1";
        protected HtmlInputHidden SumRecord;

        protected void DataGridInfo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.DataItemIndex == -1)
            {
                this.DataGridInfo.Attributes.Add("oldValue", "#FFFFFF");
                this.DataGridInfo.Attributes.Add("singleValue", "#FFFFFF");
            }
            else
            {
                e.Row.Attributes.Add("onmouseover", "this.bgColor='#F6F5F5'");
                if ((e.Row.DataItemIndex % 2) == 0)
                {
                    e.Row.Attributes.Add("bgcolor", "#FFFFFF");
                    e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('singleValue')");
                }
                else
                {
                    e.Row.Attributes.Add("bgcolor", "#FFFFFF");
                    e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('oldValue')");
                }
            }
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Cells[0].Text = this.publicFun_0.RemoveHTML(e.Row.Cells[0].Text).Replace("&lt;BR&gt;", "").Replace("&lt;br&gt;", "").Replace("&nbsp;", "");
                string text = e.Row.Cells[0].Text;
                if (e.Row.Cells[0].Text.Length > 40)
                {
                    e.Row.Cells[0].Text = "<a title=" + e.Row.Cells[0].Text + ">" + e.Row.Cells[0].Text.Substring(0, 40) + "…</a>";
                }
                Label label = (Label) e.Row.Cells[3].FindControl("labSumF");
                TextBox box1 = (TextBox) e.Row.Cells[3].FindControl("txtRubricAFen");
                label.Text = Convert.ToString((int) (text.Replace("___", "〓").Split(new char[] { '〓' }).Length - 1));
            }
        }

        private void method_0()
        {
            string selectCommandText = "";
            string[] strArray = this.string_0.Split(new char[] { ',' });
            string str2 = "";
            for (int i = 0; i < strArray.Length; i++)
            {
                if (strArray[i].Trim() != "")
                {
                    if (str2.Trim().Length != 0)
                    {
                        str2 = str2 + " or SubjectID='" + strArray[i].Trim() + "' ";
                    }
                    else
                    {
                        str2 = " (SubjectID='" + strArray[i].Trim() + "' ";
                    }
                }
            }
            if (!(str2.Trim() != ""))
            {
                str2 = " ID<>0 ";
            }
            else
            {
                str2 = str2 + ")";
            }
            if (!(this.string_2.Trim() == "1"))
            {
                selectCommandText = "select a.ID,a.RubricTitle,Difficulty=case a.Difficulty when 'A' then '难' when 'B' then '较难' when 'C' then '中等' when 'D' then '较易' when 'E' then '容易' end from  RubricInfo a,SubjectInfo b where a.SubjectID=b.ID and a.RubricType='J' and a.Flag='" + this.string_1 + "' and  a.IsDel='N' and " + str2 + " and (CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "')  order by a.ID ";
            }
            else
            {
                selectCommandText = "select a.ID,a.RubricTitle,Difficulty=case a.Difficulty when 'A' then '难' when 'B' then '较难' when 'C' then '中等' when 'D' then '较易' when 'E' then '容易' end from  RubricInfo a,SubjectInfo b where a.SubjectID=b.ID and a.RubricType='J' and a.Flag='" + this.string_1 + "' and  a.IsDel='N' and " + str2 + " and (IsShare='A' or (IsShare='B' and CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "'))  order by a.ID ";
            }
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommandText, selectConnection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "RubricInfo");
            this.SumRecord.Value = dataSet.Tables["RubricInfo"].Rows.Count.ToString();
            this.DataGridInfo.DataSource = dataSet.Tables["RubricInfo"].DefaultView;
            this.DataGridInfo.DataBind();
            adapter.Dispose();
            dataSet.Dispose();
            selectConnection.Dispose();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_3 = new HttpCookie("ExamUserLevel");
            this.httpCookie_3 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_4 = new HttpCookie("ExamDeptID");
            this.httpCookie_4 = base.Request.Cookies["ExamDeptID"];
            this.httpCookie_2 = new HttpCookie("ExamDeptName");
            this.httpCookie_2 = base.Request.Cookies["ExamDeptName"];
            if (!((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false))
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
            else
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                this.httpCookie_4.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_4.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.string_0 = base.Request["SubjectID"].ToString();
                this.string_1 = base.Request["ExamType"].ToString();
                this.string_2 = base.Request["ReadOther"].ToString();
                if (!base.IsPostBack)
                {
                    this.method_0();
                }
            }
        }
    }
}

